@namespace DevToys.Blazor.Components.UIElements
@using DevToys.Api;
@inherits ComponentBase

<Button id="@UIButton.Id"
        IsVisible="@UIButton.IsVisible"
        IsEnabled="@UIButton.IsEnabled"
        HorizontalAlignment="@UIButton.HorizontalAlignment"
        VerticalAlignment="@UIButton.VerticalAlignment"
        Appearance="@((UIButton.IsAccent ? ButtonAppearance.Accent : UIButton.IsHyperlink ? ButtonAppearance.Hyperlink : ButtonAppearance.Neutral))"
        @onclick=OnButtonClickAsync>
    @if (!string.IsNullOrWhiteSpace(UIButton.IconFontName) && UIButton.IconGlyph != '\0')
    {
        <StackPanel Orientiation="UIOrientation.Horizontal" Spacing="4">
            <FontIcon Glyph="@UIButton.IconGlyph"
                      FontFamily="@UIButton.IconFontName"
                      Height="16"
                      Width="16"/>
            @if (!string.IsNullOrEmpty(UIButton?.Text))
            {
                <TextBlock Text="@UIButton?.Text" NoWrap="true" />
            }
        </StackPanel>
    }
    else
    {
        <TextBlock Text="@UIButton?.Text" NoWrap="true" />
    }
</Button>